#include <stdio.h>
#include <graphics.h>
#include <conio.h>
#define Pi 3.14159

int main()
{
	int height, weight;
	int centerX, centerY, radius;
	float offset, totaloffset=0;
	
	height = 600;
	weight = 800;

	initgraph(weight, height);
	setbkcolor(RGB(128,128,128));
	cleardevice();

	do
	{
		for (centerX = 100; centerX < 800; centerX += 200)
		{
			for (centerY = 100; centerY < 600; centerY += 200)
			{
				totaloffset = 0;
				float h = rand() % 180;
				COLORREF color1 = HSVtoRGB(h, 0.9, 0.8);
				COLORREF color2 = HSVtoRGB(h + 180, 0.9, 0.8);

				for (radius = 100; radius > 0; radius -= 25)
				{
					int left = centerX - radius;
					int right = centerX + radius;
					int top = centerY - radius;
					int bottom = centerY + radius;

					for (int i = 0; i < 20; i++)
					{
						offset = i * Pi / 10 + totaloffset;

						setfillcolor(color1);
						solidpie(left, top, right, bottom, offset, 2 * Pi / 60 + offset);
						setfillcolor(RGB(255, 255, 255));
						solidpie(left, top, right, bottom, 2 * Pi / 60 + offset, 3 * Pi / 60 + offset);
						setfillcolor(color2);
						solidpie(left, top, right, bottom, 3 * Pi / 60 + offset, 5 * Pi / 60 + offset);
						setfillcolor(RGB(0, 0, 0));
						solidpie(left, top, right, bottom, 5 * Pi / 60 + offset, 6 * Pi / 60 + offset);
					}
					totaloffset += Pi / 20;
				}
			}
		}
	} while (_getch() == ' ');
	

	_getch();
	return 0;
}